﻿
@{
    ViewData["Title"] = "简化文书检索";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section head{
    <link href="/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet" />
    <link href="/css/select2/select2.min.css" rel="stylesheet" />
    <style type="text/css">
        .dSearch .btn {
            margin-top: -3px;
        }

        .dSearch .form-control {
            display: inline-block;
        }

        .dSearch .layer-date {
            margin-top: -7px;
        }

        .dataTables_wrapper {
            padding-bottom: 0px;
        }

        div.dataTables_scrollBody table {
            margin-top: -18px !important;
        }

        .fixed-table-pagination .pagination-detail, .fixed-table-pagination div.pagination {
            margin-bottom: 0px;
        }

        .layui-layer-iframe iframe {
            overflow-y: hidden;
        }
        #searchbtn {
            margin-top: 10px;
            font-size: 10pt;
            line-height: 16px;
            height: 30px;
        }
    </style>
}
<form id="form1" runat="server">
    <div id="dMain">
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="ibox" style="margin-bottom: 0px;">
                <div class="ibox-title">
                    <h5>简化文书数据检索</h5>
                </div>
                <div class="ibox-content">
                    <div id="collapseOne" class="panel-collapse collapse">
                        <div class="panel-body">
                            <div class="dSearch">
                                 <input type="text" id="txtFileNo" class="form-control" placeholder="档号" style="width:130px;" />
                                 <select id="ddlFType" class="form-control" style="width:130px;" placeholder="机构或问题"></select>
                                <input type="text" id="txtND1" class="form-control" style="width:80px;" placeholder="开始年度" onclick="WdatePicker({dateFmt: 'yyyy'})" />
                                至
                                <input type="text" id="txtND2" class="form-control" style="width:80px;" placeholder="结束年度" onclick="WdatePicker({dateFmt: 'yyyy'})" />
                                <select id="ddlFTerm" class="form-control" style="width:100px;" placeholder="期限"></select>
                                 <input type="text" ID="txtZRZ" Class="form-control" placeholder="责任者" style="width:130px;" />
                                 <input type="text" ID="txtWH" Class="form-control" placeholder="文号" style="width:130px;" />
                                 <input type="text" ID="txtAJTM" Class="form-control" placeholder="案卷题名" style="width:200px;" />
 
                                <button type="button" style="margin-left:50px" id="btn_query" class="btn btn-sm btn-primary">&nbsp;检索</button>
                            </div>
                            </div>
                        </div>
                    <div id="toolbar">
                        <a data-toggle="collapse" data-parent="#accordion" id="searchbtn" class="btn btn-sm btn-primary" href="tabs_panels.html#collapseOne">检索</a>
                        <a class="btn btn-sm btn-primary  btn-pd" onclick="Apply()" style="margin-top: 10px;">阅卷申请</a>
                        @*@if (IsImport == 1)*@

                        <a class="btn btn-sm btn-primary  btn-pd" onclick="InsSearchPrint()" style="margin-top: 10px; margin-left: 10px;">归档文件目录打印</a>

                        @*<div class="text-danger" style="font-size: 14px; position: absolute; margin-top: 15px; margin-left: 80px"><i class="fa fa-hand-o-right"></i>&nbsp;提示：双击行可查看该简化文书档案的详细信息！</div>*@
                    </div>
                            <table id="tabData" class="table table-bordered" style="min-width:2500px;">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>档号</th>
                                        <th>件号</th>
                                        <th>机构（问题）</th>
                                        <th>责任者</th>
                                        <th>文号</th>
                                        <th>题名</th>
                                        <th>期限</th>
                                        <th>归档年度</th>
                                        <th>文件形成时间</th>
                                        <th>归档日期</th>
                                        <th>档案门类代码</th>
                                        <th>全宗名称</th>
                                        <th>全宗号</th>
                                        <th>控制标识</th>
                                        <th>页数</th>
                                        <th>盒号</th>
                                        <th>密级</th>
                                        <th>备注</th>
                                        <th>状态</th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
    </div>
</form>
@section scripts{

    @*<script src="/js/jquery.cookie.js"></script>*@
    <script src="/js/plugins/jeditable/jquery.jeditable.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-export.js"></script>
    <script src="/js/plugins/bootstrap-table/tableExport.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-cookie.js"></script>
    @*<script src="/js/plugins/bootstrap-table/bootstrap-table-maintainColSwitch.min.js"></script>*@
    <script src="/js/My97DatePicker/WdatePicker.js"></script>
    <script src="/js/plugins/layer/layer.min.js"></script>
    <script src="/js/store.js"></script>
    <script src="/js/verification.js"></script>
    <script src="/js/select2/select2.min.js"></script>
    <script src="/js/zuiCode.js"></script>

    <script type="text/javascript">
        $(function () {
            $("#btn_query").click(function () {
                $("#tabData").bootstrapTable('refresh');
                });
            var tabHeight = document.documentElement.clientHeight - 100;
            $('#ddlFType').select2({ placeholder:"机构或问题"});
            $('#ddlFTerm').select2({ placeholder:"期限"});
            $('#tabData').bootstrapTable({
                height: tabHeight,
                url: "@Url.Action("GetJHWenShuJsonData", "JHWenShu")",
                dataType: "json",
                columns: [
                    { field: 'ID', align: 'center', width: "40px", checkbox: true, sortable: false },
                    { align: 'left',  width: "300px",  sortable: true, formatter: operateFormatter2 },
                    { field: 'BookNum', align: 'center', width: "70px", sortable: true },
                    { field: 'FType', align: 'left', width: "150px", sortable: true },
                    { field: 'CV.ResponsiblePerson', align: 'left', width: "150px", sortable: true },
                    { field: 'CV.ArticleNo', align: 'left', width: "190px", sortable: true },
                    { field: 'CV.Title', width: "300px", align: 'left' },
                    { field: 'CV.FTermName', align: 'center', width: "100px", sortable: true },
                    { field: 'FYear', align: 'center', width: "100px", sortable: true },
                    { field: 'CV.ArticleDate', align: 'center', width: "100px", sortable: true },
                    { field: 'CV.KeptFileDate', align: 'center', width: "100px", sortable: true },
                    { field: 'CV.DAMLDM', align: 'center', width: "100px", sortable: true },
                    { field: 'CV.QZMC', align: 'center', width: "100px", sortable: true },
                    { field: 'CV.QZH', align: 'center', width: "100px", sortable: true },
                    { field: 'CV.KZBS', align: 'center', width: "100px", sortable: true },
                    { field: 'CV.PageCount', align: 'center', width: "80px", sortable: true },
                    { field: 'CV.CaseFRef', align: 'center', width: "80px", sortable: true },
                    { field: 'CV.MLevel', align: 'center', width: "80px", sortable: true },
                    { field: 'CV.Remarks', align: 'center', width: "80px", sortable: true },
                    { align: 'center', width: "100px", sortable: true, formatter: fileState }
                ],
                toolbar: '#toolbar',//工具按钮用哪个容器
                buttonsClass: "sm btn-white",//按钮class
                queryParams: queryParams,//传递参数（*）
                //queryParamsType:"limit",
                sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）
                pageSize: 50,//分页条数
                pageNumber: 1,    //初始化加载第一页，默认第一页
                clickToSelect: true,//设置true 将在点击行时，自动选择单选或复选框
                singleSelect: false,//为true则禁止多选
                uniqueId: "ID", //每一行的唯一标识，一般为主键列
                cache: false,//是否缓存
                cookie: true,//是否启用cookie
                cookieIdTable: "InsSearch2",//cookie键值
                pagination: true,//是否分页
                pageList: [50, 100, 200, 500, 1000],
                exportDataType: 'selected',
                silent: true,
                showColumns: true,//是否显示所有的列
                //maintainColSwitch: true,  //保持显示隐藏列参数,使用默认参数传入 true 即可
                //switchable:true,
                //showToggle: true,//是否显示详细视图和列表视图的切换按钮
                showRefresh: true,//是否显示刷新按钮
                search: true,//是否启用搜索
                strictSearch: true,
                showPaginationSwitch: true,//是否显示分页切换按钮
                showExport: true,//是否启用导出
                striped: false,//是否显示行间隔色
                exportOptions: {
                    ignoreColumn: [0],  //忽略某一列的索引
                },
                onDblClickRow: function (row, obj) { //双击行事件
                    if (row.MLevel != "" && row.MLevel != null) {
                        showTip("是" + row.MLevel + "的文件", 2, 2);
                    } else if (row.Flag3 != 1) {
                        if ("<%=UserDMName%>" == "武汉市人民检察院" || "<%=UserDMName%>" == "武汉市武昌区人民检察院" || row.InputFlag == "4") {
                            window.top.showFullPage("图像阅读器（" + (row.FileNo) + "）", "/SeeJHWSM.aspx?FID=" + row.AFID + "&ClassName=简化文书");
                        }
                        else {
                            window.top.showFullPage("图像阅读器（" + (row.FileNo) + "）", "/See.aspx?FID=" + row.AFID + "&ClassName=简化文书");
                        }
                    }
                    else if (row.Flag3 == 1) {
                        showTip("档案被封存,无法查看原文件", 2, 2);
                    }
                },
                classes: "table table-bordered table-striped table-sm table-dark",

                //rowStyle: rowStyle,//通过自定义函数设置行样式


                //onColumnSwitch: function (field, checked) {

                //    //把它存到cookie里
                //    $.cookie(field, checked);
                //},
                onSearch: function (text) {


                },
                onLoadSuccess: function (params) {
                    //加载成功时
                    var text = params.search;
                    if (text != "") {
                        //清除之前查询的高亮
                        $("#tabData tbody tr td:not(.bs-checkbox)").each(function (i) {
                            $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).html().replace("<span class='bg-yellow'>", "");
                            $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).html().replace("</span>", "");
                        });
                        $("#tabData tbody tr td:not(.bs-checkbox)").each(function (i) {
                            var str = "<span class='bg-yellow'>" + text + "</span>";
                            var NewText = $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).html().replaceAll(text, str);
                            $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).html(NewText);
                        });
                    }
                }
            });
            function fileState(value, row, index) {
                if (row.Flag3 == 0) {
                    return ["<p class=\"text-success\">正常</p>"];
                }
                else if (row.Flag3 == 1) {
                    return ["<p class=\"text-danger\">封存</p>"];
                }
            }
        })

        ////根据cookie显示隐藏显示列
        //function visible(name) {

        //    //获取cookie的值
        //    var cookieVal = $.cookie(name);  //读取name为visibleVal的值
        //    //如果没有设置cookie
        //    if (cookieVal == undefined) {
        //        return true
        //    } else {
        //        //如果有返回true,否则返回false
        //        if (($.cookie(name)) == "true") {
        //            return true
        //        } else {
        //            return false
        //        }
        //    }
        //}

        //function rowStyle(row, index) {
        //    var style = {};
        //    if (row.BookNum < 10) {               
        //        style = { css: { ' background-color': '#ed5565' } };
        //    }
        //    return style;
        //}

        function operateFormatter2(value, row, index) {
            return [
                "<i class=\"fa fa-file-picture-o\" style='color: " + (row.TureCount != 0 ? "#38B03F" : "#bbb") + "'></i>&nbsp;" + (row.FileNo)
            ];
        }
        function MetadataFormatter(value, row, index) {
            return [
                "<a title=\"元数据\" class=\"text-success\" href=\"javascript:;\" onclick=\"showPage('元数据信息(" + row.FileNo + ")','scan2/MetadataWS.aspx?ID=" + row.ID + "',510,500,true)\">元数据</a>&emsp;"
            ];
        }
        //阅卷申请
        function Apply() {
            var FilesApply_FIDS = "";
            $.map($('#tabData').bootstrapTable('getSelections'), function (row) {
                if (FilesApply_FIDS == "") {
                    FilesApply_FIDS += row.AFID;
                }
                else {
                    FilesApply_FIDS += "," + row.AFID;
                }
            });

            if (FilesApply_FIDS != "") {
                store.set("FilesApply_FIDS", FilesApply_FIDS);
                showPage("阅卷申请", "/FilesApply/Apply.aspx", 700, 500, false);
            }
        }
        //归档文件打印
        function InsSearchPrint() {
            var SelRow = $('#tabData').bootstrapTable('getSelections');
            if (SelRow.length > 0) {
                var FIDS = "";
                for (var i = 0; i < SelRow.length; i++) {
                    var FID = SelRow[i].AFID;
                    FIDS += ",'" + FID + "'";
                }
                FIDS = FIDS.replace(',', '');//去掉第一个符号
                store.set("InsSearchPrintFIDS", FIDS);

                showPage("归档文件目录打印", "InsSearchPrint.aspx", 1200, 600, false);
            }
        }
        //得到查询的参数
        var queryParams = function (params) {
            var filesQueryJson = new Object();   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
               filesQueryJson.PageIndex = params.pageNumber,   //页码
               filesQueryJson.PageSize = params.limit, //页面大小
               filesQueryJson.Order= params.order,//排序方式
               filesQueryJson.Sort = params.sort,//排序字段
               filesQueryJson.IsPaging=true,
               filesQueryJson.FileNo= $("#txtFileNo").val(),
               filesQueryJson.FType= $("#ddlFType").val(),
               filesQueryJson.FYear=$("#txtND1").val(),
               filesQueryJson.FYear2=$("#txtND2").val(),
               filesQueryJson.FTerm=$("#ddlFTerm").val(),
               filesQueryJson.ZRZ=$("#txtZRZ").val(),
               filesQueryJson.WH= $("#txtWH").val(),
               filesQueryJson.AJTM= $("#txtAJTM").val(),
               filesQueryJson.search= params.search
            var jsonfilesQueryJson = { 'filesQueryJson': JSON.stringify(filesQueryJson) };
           return jsonfilesQueryJson;
        };


    </script>
}
